package com.kermel.andromeda;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;

import com.kermel.andromeda.activities.dbtool.manage.DatabaseManagementActivity;
import com.kermel.andromeda.activities.dbtool.viewalarms.ViewAlarmsActivity;
import com.kermel.andromeda.data.persistence.AndromedaDatabaseManager;

public class AndromedaDatabaseTool extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        View dbManagementButton = findViewById(R.id.dbManagementButton);
        if (dbManagementButton != null)
            dbManagementButton.setOnClickListener(new ManageDatabaseAction());
        
        View viewAlarmsButton = findViewById(R.id.viewAlarmsButton);
        if (viewAlarmsButton != null)
            viewAlarmsButton.setOnClickListener(new ViewAlarmsAction());
        
        AndromedaDatabaseManager.instance.initializeDatabase(this);
    }
    
    private void launchManageDatabaseActivity() {
        Intent intent = new Intent(this, DatabaseManagementActivity.class);
        startActivity(intent);
    }
    
    private void launchViewAlarmsActivity() {
        Intent intent = new Intent(this, ViewAlarmsActivity.class);
        startActivity(intent);
    }
    
    private class ManageDatabaseAction implements OnClickListener {
        public void onClick(View v) {
            launchManageDatabaseActivity();
        }
    }
    
    private class ViewAlarmsAction implements OnClickListener {
        public void onClick(View v) {
            launchViewAlarmsActivity();
        }
    }
}